package com.ugoodtech.mdcc.core.utils;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Kotone
 * Date: 2018/7/11
 * Time: 14:47
 * To change this template use File | Settings | File Templates.
 */
public class ArrayStringUtil {

    public static List<Long> getStringIds(String ids) {
        List<Long> longIdArray=new ArrayList<>();
        if(!StringUtils.isEmpty(ids)){
            String[]idArray=ids.split(",");
            for(String idStr:idArray){
                Long id= Long.parseLong(idStr);
                longIdArray.add(id);
            }
        }
        return longIdArray;
    }

    public static List<String> getStringList(String listStr) {
        List<String> stringArray=new ArrayList<>();
        if(!StringUtils.isEmpty(listStr)){
            String[]strArray=listStr.split(",");
            for(String str:strArray){
                stringArray.add(str);
            }
        }
        return stringArray;
    }

    public static List<String> getOnlyStringList(String listStr) {
        List<String> stringArray=new ArrayList<>();
        if(!StringUtils.isEmpty(listStr)){
            String[]strArray=listStr.split(",");
            for(String str:strArray){
                if(!stringArray.contains(str)){
                    stringArray.add(str);
                }
            }
        }
        return stringArray;
    }

}
